/**
 * 千分位分割
 * @params num
 * @returns
 */
export function toThousandFilter(num: undefined | number | string) {
  if (num === undefined || num === 'undefined' || num === null || num === 'null') return ''
  return (null || 0).toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
}
/**
 * 千分位分割，保留小数
 * @params num
 * @params fixed
 * @returns
 */
export function toFixedThousandFilter(num: undefined | number | string, fixed = 2) {
  if (num === undefined || num === 'undefined' || num === null || num === 'null') return ''
  return (null || 0).toFixed(fixed).replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
}
